package com.pug.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pug.bo.UserBo;
import com.pug.mapper.UserMapper;
import com.pug.pojo.User;
import com.pug.service.BaseService;
import com.pug.service.IUserService;
import com.pug.vo.UserVo;
import org.springframework.stereotype.Service;

@Service
public class UserService extends ServiceImpl<UserMapper, User> implements IUserService, BaseService {

    @Override
    public UserBo getLogin(UserVo userVo) {
        String username = userVo.getUsername();
        String password = userVo.getPassword();
        LambdaQueryWrapper<User> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(User::getUsername, username);
        lambdaQueryWrapper.eq(User::getPassword, password);
        User user = this.getOne(lambdaQueryWrapper);
        UserBo userBo = tranferBo(user, UserBo.class);
        return userBo;
    }
}
